//SEMS Method
define(["app"], function (app) {
	app.config(function($provide){
		$provide.decorator('MMWService', function ($delegate, $rootScope, $filter) {
			$delegate.reportInfoGet = function(content, feedback){
				//20180525 modify by 李栋 for mantis#0046985
				$delegate.sendToSMESServer({
					uri: 'tcSMES_ReportInfoGet.clsSMES.report_info_get_json',
					content : content,
					success : function(data){
						feedback(data.recordlist);
					}
				});
			};

			$delegate.pageNumberInfoGet = function(content, feedback, errorback){
				$delegate.sendToServer({
					uri: 'ServicesSTD.Module_SYS.page_number_info_get',
					content : content,
					success : function(data){
						feedback(data.page_number_info_get);
					},
                    error:errorback
				});
			};

			$delegate.showSelectPNIG = function(content, title, selectCode, feedback, cancel){
				var label = 'page_no';
				if(content.page_mode == '15'){
					label = 'page_name';
				} else if(content.page_mode == '0' || content.page_mode == '4' || content.page_mode == '5' || content.page_mode == '2'){
					label = 'page_display';
				}
				$delegate.pageNumberInfoGet(content, function(itemList){
					$rootScope.showSelect({
						title : title,
						label : label,
						code : 'page_no',
						selectCode : selectCode,
						list : itemList,
						confirm : function(item, dialog){
							dialog.hide();
							feedback(item);
						},
						cancel:cancel
					});
				});
			};

			$delegate.showQueryListPNIG = function(options){
				$rootScope.showQueryList({
			        setting: options.setting, // 20201228 FOR 83491 自定义排版
                    mode:options.mode,
					condition: options.condition,
					key:options.key||options.header[0].code,
					order:options.order,
					/*notQuery:true,*/
					back:options.back,
					beforeShown:options.beforeShown,
					selectCode:options.selectCode,
					selectItem:options.selectItem,
                    selectKey:options.selectKey,
					header : options.header,
					filterColumns:options.filterColumns,
                    notQuery: options.notQuery,
					pageRecord : options.pageRecord,
					query: function(conditions, feedback){
						var content = {
							page_mode : options.page_mode,
							form_name : options.form_name
						};
						if(options.setCondition)
							content.query_condition_info = options.setCondition(conditions);
						else
							content.query_condition_info = conditions;

                        $delegate.sendToServer({
                            uri: 'ServicesSTD.Module_SYS.page_number_info_get',
							content : content,
							success : function(data){
								if(feedback)
									feedback(data.page_number_info_get);
							}
						});
					},
                    noDataException: options.noDataException,
					confirm: function(selectItem, dialog){
						dialog.hide();
						options.confirm(selectItem, dialog);
					},
                    cancel: options.cancel
				});
			};

			return $delegate;
		});
	});
});
